import tools from '@/utils/tools';
const { toLine } = tools;


export default {
    // 重构歌手、专辑、曲作家、词作家
    setSelectParams: (_key, params) => {
        let newArr = [];
        let key = toLine(_key); // 驼峰转下划线
        key = key.indexOf('_') === 0 ? key.substring(1) : key;

        params.map((item, index) => {
            newArr.push({
                value: item[`${key}_id`],
                defaultValue: item[`${key}_id`],
                label: item[`${key}_name`],
            })
        })
        return newArr;
    },
    // 重构分类标签
    resetTags(params) {
        let data = params;
        let { sub, categories } = data;
        let newArr = [];
        for (let key in categories) {
            newArr[key] = {
                name: categories[key],
                tags: []
            }
        }

        sub.map((item) => {
            newArr[item.category].tags[item.id] = item;
        })
        return newArr;
    }

}